/*
 * @Author: 杨上漂
 * @Date: 2024-10-12 18:11:57
 * @LastEditors: 杨上漂
 * @LastEditTime: 2024-10-16 18:11:32
 * @FilePath: \gwlc\assets\scripts\Player.ts
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
import { _decorator, Component, director, find, instantiate, Label, Light, macro, Node, ParticleSystem2D, Pool, Prefab, ProgressBar, resources, sp, Sprite, SpriteFrame, UITransform, v2, v3 } from 'cc';
import { playerSkillTypeEnum } from '../Enum';
import { Dictionary } from '../utils/Dictionary';
import { gameMgr } from './gameMgr';
import { SelectSkillPanel } from './SelectSkillPanel';
import { EnemyMgr } from './EnemyMgr';
import { StarlightBullet } from '../playerSkill/StarlightBullet';
import { FireBall } from '../playerSkill/FireBall';
import { SpinArrow } from '../playerSkill/SpinArrow';
import { Spike } from '../playerSkill/Spike';
import { LightFlash } from '../playerSkill/LightFlash';
import { MoonSlash } from '../playerSkill/MoonSlash';
import { Arrow } from '../playerSkill/Arrow';
import { UserInfo } from '../startScene/UserInfo';
import { StartSceneGameMgr } from '../startScene/StartSceneGameMgr';
import { Adsdk } from '../Adsdk';
import { AudioMgr } from '../utils/AudioMgr';
import { TimeCountTable } from '../TimeCountTable';
import { PoolMgr } from '../PoolMgr';

const { ccclass, property } = _decorator;

@ccclass('Player')
export class Player extends Component {

    static ins: Player;
    playerHpBar: ProgressBar;
    selectSkillCountTimeBar: ProgressBar;
    @property(Prefab)
    starlightPre: Prefab;
    @property(Prefab)
    spinArrow: Prefab;
    @property(Prefab)
    spikePre: Prefab;
    @property(Prefab)
    lightPre: Prefab;
    @property(Prefab)
    fireBallPre: Prefab;
    @property(Prefab)
    moonSlashPre: Prefab;
    @property(Prefab)
    skillCellItemPre:Prefab;
    selectSkillPanel:Node;
    lvLabel:Node;
    hpLabel:Node;

    // tempUpdatSkillTimeCount=0;
    private tempUpdatNormalArrowTimeCount=100;
    private tempUpdatstarlightTimeCount=100;
    private tempUpdatFireBallTimeCount=100;
    private tempUpdatspinArrowTimeCount=100;
    private tempUpdatSpikeTimeCount=100;
    private tempUpdatMoonTimeCount=100;
    private tempUpdatLightTimeCount=100;

    isOpenRabid=false;//是否开启了大招卡的狂暴状态
    waitHandleUpSkillLevelNum=0;//等待总共升级排队的数

    get TempUpdatNormalArrowTimeCount(){
        return this.tempUpdatNormalArrowTimeCount;
    }
    set TempUpdatNormalArrowTimeCount(value){
         this.tempUpdatNormalArrowTimeCount=value;
         if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.normalArrow)) {
            this.skillItemNodeDic.get(playerSkillTypeEnum.normalArrow).getChildByName("sp").getComponent(Sprite).fillRange=value/this.arrowFrequency
         }
    }

    get TempUpdatstarlightTimeCount(){
        return this.tempUpdatstarlightTimeCount;
    }
    set TempUpdatstarlightTimeCount(value){
         this.tempUpdatstarlightTimeCount=value;
         if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.starLightBullet)) {
            this.skillItemNodeDic.get(playerSkillTypeEnum.starLightBullet).getChildByName("sp").getComponent(Sprite).fillRange=value/this.starLightBulletFrequency
         }
    }

    get TempUpdatFireBallTimeCount(){
        return this.tempUpdatFireBallTimeCount;
    }
    set TempUpdatFireBallTimeCount(value){
         this.tempUpdatFireBallTimeCount=value;
         if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.fireBall)) {
            this.skillItemNodeDic.get(playerSkillTypeEnum.fireBall).getChildByName("sp").getComponent(Sprite).fillRange=value/this.fireBallFrequency
         }
    }

    get TempUpdatspinArrowTimeCount(){
        return this.tempUpdatspinArrowTimeCount;
    }
    set TempUpdatspinArrowTimeCount(value){
         this.tempUpdatspinArrowTimeCount=value;
         if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.spinArrow)) {
            this.skillItemNodeDic.get(playerSkillTypeEnum.spinArrow).getChildByName("sp").getComponent(Sprite).fillRange=value/this.spinArrowFrequency
         }
    }

    get TempUpdatLightTimeCount(){
        return this.tempUpdatLightTimeCount;
    }
    set TempUpdatLightTimeCount(value){
         this.tempUpdatLightTimeCount=value;
         if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.light)) {
            this.skillItemNodeDic.get(playerSkillTypeEnum.light).getChildByName("sp").getComponent(Sprite).fillRange=value/this.lightFrequency
         }
    }

    get TempUpdatSpikeTimeCount(){
        return this.tempUpdatSpikeTimeCount;
    }
    set TempUpdatSpikeTimeCount(value){
         this.tempUpdatSpikeTimeCount=value;
         if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.spike)) {
            this.skillItemNodeDic.get(playerSkillTypeEnum.spike).getChildByName("sp").getComponent(Sprite).fillRange=value/this.spikeFrequency
         }
    }

    get TempUpdatMoonTimeCount(){
        return this.tempUpdatMoonTimeCount;
    }
    set TempUpdatMoonTimeCount(value){
         this.tempUpdatMoonTimeCount=value;
         if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.moonSlash)) {
            this.skillItemNodeDic.get(playerSkillTypeEnum.moonSlash).getChildByName("sp").getComponent(Sprite).fillRange=value/this.MoonFrequency
         }
    }

    // maxHp = 20;

    // UpSkillTotalTime = 5;

    playerSkillInfoDic:Dictionary<number,number>=new Dictionary();//玩家技能信息字典,key:技能类型,value：等级
    playerSkillInfoDetailDic:Dictionary<number,number>=new Dictionary();//玩家详细技能信息字典,key:技能类型,value：等级
    skillItemNodeDic:Dictionary<number,Node>=new Dictionary()//技能格子node字典


    //#region 玩家属性
    arrowAttackMun;
    arrowSpeed;
    arrowFrequency;//几秒发射一次,该变量越低速度越快
    arrowSlotMun;//弓箭槽位，一次能发射几只，游戏里可能看见弓箭重叠
    arrowMaxAttackEnenmyMun;//弓箭最大分裂
    arrowCriticalHit;//暴击率

    starLightBulletAttackMun;
    starlightSpeed;
    starLightBulletFrequency;
    starLightMaxAttackEnenmyMun;//槽位，一次能发射几只
    starLightIsCanThrough;//是否可以穿透

    fireBallAttackMun;
    fireBallSpeed;
    fireBallFrequency;
    fireBallMaxAttackEnenmyMun;//槽位，一次能发射几只
    fireBallIsCanFiring;//是否可灼烧
    FiringDamage;//灼烧伤害
    FiringSustainTime;//灼烧持续时间

    spinArrowAttackMun;
    spinArrowForce;//力度，力度越大，抛掷越远
    spinArrowFrequency;//几秒发射一次,该变量越低速度越快
    spinArrowMaxAttackEnenmyMun;

    spikeAttackMun;
    spikeFrequency;//几秒发射一次
    spikeMaxAttackEnenmyMun;
    spikeIsCanSlowDown;//是否可以减速

    MoonAttackMun;
    MoonFrequency;//几秒发射一次
    moonMaxAttackEnenmyMun;
    moonIsCanFrozen;//是否可以冰冻
    moonFrozenSustainTime;//冰冻持续时间

    lightAttackMun;
    lightFrequency;//几秒发射一次
    lightMaxAttackEnenmyMun;
    lightIsCanscorch;//是否可以烧焦
    lightScorchSustainTime;//烧焦持续时间


    //#endregion

    // private currSkillTimeCount = this.UpSkillTotalTime;

    private currSkillEXP=0;

    // private currHp: number = this.maxHp;

    private lv:number=1;

    get Lv(){
        return this.lv;
    }

    set Lv(value) {
        this.lv = value;
        console.log(this.lv,"lv")
        this.lvLabel.getComponent(Label).string="Lv."+this.lv
    }


    upSkillEx = 2;

    set CurrSkillEXP(value) {

        if(this.Lv>=20){
            return
        }

        this.currSkillEXP = value;
        let upSkillEx = this.upSkillEx
        if(this.Lv>1){
            upSkillEx = this.upSkillEx+(this.upSkillEx*0.1)
        }
        if(!Number.isInteger(upSkillEx)){
            upSkillEx = Math.ceil(upSkillEx);
        }

        if(this.currSkillEXP>=upSkillEx){

            this.waitHandleUpSkillLevelNum+=1;
            this.currSkillEXP = 0
            this.upSkillEx = upSkillEx

        }
        this.selectSkillCountTimeBar.progress = this.currSkillEXP / upSkillEx;
    }

    get CurrSkillEXP() {
        return this.currSkillEXP;
    }


    //初始化玩家内的属性值
    initData() {

        console.log("玩家属性值初始化")
        // this.maxHp = 30;
        // this.CurrHp = this.maxHp;
        this.Lv=1;
        EnemyMgr.ins.enemyId=0;
        this.playerSkillInfoDic.set(playerSkillTypeEnum.normalArrow,1);
        this.upSkillEx = 2 //升级经验
        this.CurrSkillEXP = 0;
        TimeCountTable.ins.elapsedTime=0;

        let pre = instantiate(this.skillCellItemPre);
        pre.setParent(gameMgr.ins.skillCellContent);
        pre.setPosition(0, 0, 0);
        resources.load(`${gameMgr.ins.skillCongfiDic.get(playerSkillTypeEnum.normalArrow).iconPath}/spriteFrame`, SpriteFrame, (err, res) => {
            pre.getChildByName("sp").getComponent(Sprite).spriteFrame = res
        })
        pre.getChildByName("Label").getComponent(Label).string = "1"
        this.skillItemNodeDic.set(playerSkillTypeEnum.normalArrow, pre);

        let selfRole=UserInfo.hasRoleDic.get(UserInfo.currGoBattleRoleId)
        //普通攻击
        this.arrowAttackMun = selfRole.roleAttackAttribute;
        this.arrowSpeed = 30;
        this.arrowFrequency = selfRole.roleFrequencyAttribute;//几秒发射一次,该变量越低速度越快
        // this.arrowFrequency = 0.2;//几秒发射一次,该变量越低速度越快
        this.arrowCriticalHit=selfRole.roleCriticalHitAttribute
        this.arrowSlotMun = 1;//弓箭槽位，一次能发射几只，游戏里可能看见弓箭重叠
        this.arrowMaxAttackEnenmyMun=1;//弓箭最大分裂

        //星光箭
        this.starLightBulletAttackMun = 80;
        this.starlightSpeed = 40;
        this.starLightBulletFrequency = 7;
        this.starLightMaxAttackEnenmyMun = 1;//槽位，一次能发射几只
        this.starLightIsCanThrough = false;//是否可以穿透

        //火球
        this.fireBallAttackMun = 50;
        this.fireBallSpeed = 20;
        this.fireBallFrequency = 5;
        this.fireBallMaxAttackEnenmyMun = 1;//槽位，一次能发射几只
        this.fireBallIsCanFiring = false;//是否可灼烧
        this.FiringDamage = 10;//灼烧伤害
        this.FiringSustainTime = 3;//灼烧持续时间

        //香蕉
        this.spinArrowAttackMun = 60;
        this.spinArrowForce = 3100;//力度，力度越大，抛掷越远
        this.spinArrowFrequency = 7;//几秒发射一次,该变量越低速度越快
        this.spinArrowMaxAttackEnenmyMun = 1;

        //地刺
        this.spikeAttackMun=50;
        this.spikeFrequency=5;//几秒发射一次
        this.spikeMaxAttackEnenmyMun=2;
        this.spikeIsCanSlowDown=false;//是否可以减速
        //西瓜斩
        this.MoonAttackMun = 30;
        this.MoonFrequency = 6;//几秒发射一次
        this.moonMaxAttackEnenmyMun = 1;
        this.moonIsCanFrozen = false;//是否可以冰冻
        this.moonFrozenSustainTime=3;//冰冻持续时间

        //闪电
        this.lightAttackMun=60;
        this.lightFrequency=5;//几秒发射一次
        this.lightMaxAttackEnenmyMun=1;
        this.lightIsCanscorch=true;//是否可以烧焦
        this.lightScorchSustainTime=2;//烧焦持续时间

    }

    protected onLoad(): void {
        Player.ins = this;

        this.playerHpBar = find("Canvas/UI/playerHpProgressBar").getComponent(ProgressBar);
        this.selectSkillCountTimeBar = find("Canvas/UI/selectSkillCountTimeBar").getComponent(ProgressBar);
        this.selectSkillPanel=find("Canvas/UI/selectSkillPanel");
        this.lvLabel=find("Canvas/UI/levelLabel");
        this.hpLabel=find("Canvas/UI/hpLabel");
    }

    protected update(dt: number): void {

        if (gameMgr.ins.isGamePause==false) {

            // this.tempUpdatSkillTimeCount += dt
            this.TempUpdatNormalArrowTimeCount += dt

          
            if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.starLightBullet)) {
                this.TempUpdatstarlightTimeCount += dt
            }
            if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.fireBall)) {
                this.TempUpdatFireBallTimeCount += dt
            }
            if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.spinArrow)) {
                this.TempUpdatspinArrowTimeCount += dt
            }
            if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.spike)) {
                this.TempUpdatSpikeTimeCount += dt
            }
            if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.moonSlash)) {
                this.TempUpdatMoonTimeCount += dt
            }
            if (this.skillItemNodeDic.containsKey(playerSkillTypeEnum.light)) {
                this.TempUpdatLightTimeCount += dt
            }


            // if (this.tempUpdatSkillTimeCount >= 1) {
            //     this.tempUpdatSkillTimeCount = 0;

            //         //技能升级时间
            //         this.CurrSkillTimeCount -= 1;
            // }

            //发射弓箭
            if (this.TempUpdatNormalArrowTimeCount >= this.arrowFrequency) {
                this.TempUpdatNormalArrowTimeCount = 0;

                //玩家发射弓箭
                if (EnemyMgr.ins.enemyNodeDic.lenght > 0) {//如果场上有敌人
                    this.createSkillObjectPre(playerSkillTypeEnum.normalArrow);
                }
            }

            //发射星光弹
            if (Player.ins.playerSkillInfoDic.containsKey(playerSkillTypeEnum.starLightBullet)) {
                if (this.TempUpdatstarlightTimeCount >= this.starLightBulletFrequency) {
                    this.TempUpdatstarlightTimeCount = 0;

                        //玩家发射
                        if (EnemyMgr.ins.enemyNodeDic.lenght>0) {//如果场上有敌人
                            this.createSkillObjectPre(playerSkillTypeEnum.starLightBullet);
                        }
                    }
            }

            //发射火球
            if (Player.ins.playerSkillInfoDic.containsKey(playerSkillTypeEnum.fireBall)) {
                if (this.TempUpdatFireBallTimeCount >= this.fireBallFrequency) {
                    this.TempUpdatFireBallTimeCount = 0;

                        //玩家发射
                        if (EnemyMgr.ins.enemyNodeDic.lenght > 0) {//如果场上有敌人
                            this.createSkillObjectPre(playerSkillTypeEnum.fireBall);

                        }
                    }
            }

            //发射旋转香蕉
            if (Player.ins.playerSkillInfoDic.containsKey(playerSkillTypeEnum.spinArrow)) {
                if (this.TempUpdatspinArrowTimeCount >= this.spinArrowFrequency) {
                    this.TempUpdatspinArrowTimeCount = 0;

                        //玩家发射
                        if (EnemyMgr.ins.enemyNodeDic.lenght > 0) {//如果场上有敌人
                            this.createSkillObjectPre(playerSkillTypeEnum.spinArrow);

                        }
                    }
            }

            //生成地刺
            if (Player.ins.playerSkillInfoDic.containsKey(playerSkillTypeEnum.spike)) {
                if (this.TempUpdatSpikeTimeCount >= this.spikeFrequency) {
                    this.TempUpdatSpikeTimeCount = 0;

                        //玩家发射
                        if (EnemyMgr.ins.enemyNodeDic.lenght > 0) {//如果场上有敌人
                            this.createSkillObjectPre(playerSkillTypeEnum.spike);

                        }
                    }
            }

             //生成月光斩
             if (Player.ins.playerSkillInfoDic.containsKey(playerSkillTypeEnum.moonSlash)) {
                if (this.TempUpdatMoonTimeCount >= Player.ins.MoonFrequency) {
                    this.TempUpdatMoonTimeCount = 0;

                        //玩家发射
                        if (EnemyMgr.ins.enemyNodeDic.lenght > 0) {//如果场上有敌人
                            this.createSkillObjectPre(playerSkillTypeEnum.moonSlash);
                        }
                }
            }

            //生成闪电
            if (Player.ins.playerSkillInfoDic.containsKey(playerSkillTypeEnum.light)) {
                if (this.TempUpdatLightTimeCount >= this.lightFrequency) {
                    this.TempUpdatLightTimeCount = 0;

                        //玩家发射
                        if (EnemyMgr.ins.enemyNodeDic.lenght > 0) {//如果场上有敌人
                            this.createSkillObjectPre(playerSkillTypeEnum.light);
                        }
                    }
            }

        }
    }

    createSkillObjectPre(_skillTypeEnum){
        let attackTargetNode = null;
        try{
            if(EnemyMgr.ins.getNearlyExistOneEnemyNodeNottTornado()){
                attackTargetNode = EnemyMgr.ins.getNearlyExistOneEnemyNodeNottTornado();
            }

        }catch{
            return
        }

        if (attackTargetNode) {
            if (Math.abs(attackTargetNode.getWorldPosition().y)-Math.abs(Player.ins.node.getWorldPosition().y)>StartSceneGameMgr.ins.attackEnemyNeedDistance) {
                return;
            }
        }
        else{
            return;
        }

        switch (_skillTypeEnum) {
            case playerSkillTypeEnum.normalArrow:
                this.createArrow(this.arrowMaxAttackEnenmyMun, this.arrowSlotMun);
                break;
            case playerSkillTypeEnum.fireBall:
                this.createFireBall(Player.ins.fireBallMaxAttackEnenmyMun);
                break;
            case playerSkillTypeEnum.starLightBullet:
                this.createStartlight(Player.ins.starLightMaxAttackEnenmyMun);
                break;
            case playerSkillTypeEnum.spinArrow:
                this.createSpinArrow(this.spinArrowMaxAttackEnenmyMun);
                break;
            case playerSkillTypeEnum.moonSlash:
                this.createMoonSlash(Player.ins.moonMaxAttackEnenmyMun);
                break;
            case playerSkillTypeEnum.spike:
                this.createSpike(this.spikeMaxAttackEnenmyMun);
                break;
            case playerSkillTypeEnum.light:
                this.createLigth(this.lightMaxAttackEnenmyMun);
                break;
        }

    }

    //创建弓箭，多重箭按角度攻击敌人
    createArrow(MaxAttackEnenmyMun, slotMun) {

        // this.node.getChildByName("sp").getComponent(sp.Skeleton).clearTrack(0); // 指定管道的索引
       
        // this.node.getChildByName("sp").getComponent(sp.Skeleton).setAnimation(0,"Standby",true)
        // this.node.getChildByName("sp").getComponent(sp.Skeleton).setMix("Attack","standby",0.2);
        // let arrowPre;
        // await new Promise((resolve, reject) => {
        //     resources.load(UserInfo.hasRoleDic.get(UserInfo.currGoBattleRoleId).roleTp.arrowPrePath, Prefab, (err, res) => {
        //         arrowPre = res;
        //         resolve(res);
        //     })
        // })

        // console.log(arrowPre, "arrowPre")

        let preName = UserInfo.hasRoleDic.get(UserInfo.currGoBattleRoleId).roleTp.arrowPreName;
     
        for (let i = 0; i < MaxAttackEnenmyMun; i++) {
            //获取最近单位
            let attackTargetNode = null;
            try{
                if(EnemyMgr.ins.getNearlyExistOneEnemyNodeNottTornado()){
                    attackTargetNode = EnemyMgr.ins.getNearlyExistOneEnemyNodeNottTornado();
                }

            }catch{
                return
            }

            if (!attackTargetNode) {
                return
            }

            this.node.children[0].getComponent(sp.Skeleton).setAnimation(0, "ContinuousAttack", false)

            if (i == 0) {//第一个目标
                //发射多次
                this.schedule(() => {
                    let pre = PoolMgr.ins.poolGet(preName);
                    pre.setParent(find("Canvas/bg/buttleRoot"));
                    // console.log(this.node.children[0].getChildByName("shotPos").getPosition(),"this.node.children[0].getChildByName(shotPos)")

                    let playerWorldPos=this.node.children[0].getChildByName("shotPos").getWorldPosition();
                    let resPos=find("Canvas/bg/buttleRoot").getComponent(UITransform).convertToNodeSpaceAR(playerWorldPos)
                    pre.setPosition(resPos.x, resPos.y);
                    pre.getComponent(Arrow).init(attackTargetNode.position);
                }, 0.1, slotMun - 1)
            }
            else if (i == 1) {//第二个目标
                //发射多次
                this.schedule(() => {
                    let pre = PoolMgr.ins.poolGet(preName);
                    pre.setParent(find("Canvas/bg/buttleRoot"));
                    let playerWorldPos=this.node.children[0].getChildByName("shotPos").getWorldPosition();
                    let resPos=find("Canvas/bg/buttleRoot").getComponent(UITransform).convertToNodeSpaceAR(playerWorldPos)
                    pre.setPosition(resPos.x, resPos.y);
                    pre.getComponent(Arrow).init(v2(attackTargetNode.position.x + 100, attackTargetNode.position.y));
                }, 0.1, slotMun - 1)
            }
            else if (i == 2) {//第三个目标
                //发射多次
                this.schedule(() => {
                    let pre = PoolMgr.ins.poolGet(preName);
                    pre.setParent(find("Canvas/bg/buttleRoot"));
                    let playerWorldPos=this.node.children[0].getChildByName("shotPos").getWorldPosition();
                    let resPos=find("Canvas/bg/buttleRoot").getComponent(UITransform).convertToNodeSpaceAR(playerWorldPos)
                    pre.setPosition(resPos.x, resPos.y);
                    pre.getComponent(Arrow).init(v2(attackTargetNode.position.x - 100, attackTargetNode.position.y));
                }, 0.1, slotMun - 1)
            }
        }


    }


    createStartlight(mun) {
        for (let i = 0; i < mun; i++) {
                let pre = PoolMgr.ins.poolGet("starlightBullet");
                // let pre = instantiate(this.starlightPre);
                let playerWorldPos=this.node.children[0].getChildByName("shotPos").getWorldPosition();
                let resPos=find("Canvas/bg/buttleRoot").getComponent(UITransform).convertToNodeSpaceAR(playerWorldPos)
                pre.setPosition(resPos.x, resPos.y);
                pre.setParent(find("Canvas/bg/buttleRoot"));

                pre.getComponent(StarlightBullet).init();

        }
    }

    createFireBall(mun) {
        for (let i = 0; i < mun; i++) {
            let pre = PoolMgr.ins.poolGet("fireBall");
            // let pre = instantiate(this.fireBallPre)
            pre.setParent(find("Canvas/bg/buttleRoot"));
            let playerWorldPos = this.node.children[0].getChildByName("shotPos").getWorldPosition();
            let resPos = find("Canvas/bg/buttleRoot").getComponent(UITransform).convertToNodeSpaceAR(playerWorldPos)
            pre.setPosition(resPos.x, resPos.y);

            pre.getComponent(FireBall).init();


        }
    }

    createSpinArrow(mun) {
        for (let i = 0; i < mun; i++) {
            AudioMgr.ins.playOneShot("audio/spineArrowEnemyDamage", 0.6);
            // let pre = PoolMgr.ins.poolGet("spinArrow");
            let pre = instantiate(this.spinArrow);
            pre.setParent(find("Canvas/bg/buttleRoot"));
            pre.setPosition(0, -567);
            pre.getComponent(SpinArrow).init();

        }
    }

    createSpike(mun) {
        for (let i = 0; i < mun; i++) {
            console.log("地刺术...")
                // let pre = PoolMgr.ins.poolGet("spike");
                let pre = instantiate(this.spikePre);

                // pre.setParent(find("Canvas/bg/roundRoot"));

                pre.getComponent(Spike).init();

        }
    }

    //闪电
    createLigth(mun) {
        for (let i = 0; i < mun; i++) {
                let pre = PoolMgr.ins.poolGet("Light");
                // let pre = instantiate(this.lightPre);

                pre.setParent(find("Canvas/bg/buttleRoot"));

                pre.getComponent(LightFlash).init();

        }
    }
    //月光斩
    createMoonSlash(mun) {
        for (let i = 0; i < mun; i++) {
            AudioMgr.ins.playOneShot("audio/moonDisplay", 0.6)
            // let pre = PoolMgr.ins.poolGet("moonSlash");
            let pre = instantiate(this.moonSlashPre);
            pre.getComponent(MoonSlash).init();
        }
    }

    // hurt(mun) {
    //     this.CurrHp -= mun;
    // }
}


